package com.filemanager;

import java.io.File;

public class FileManager {

    public static void batchRename(String destFile, String targetFile, FileFilter fileFilter) {
        File file = new File(destFile);
        if (!file.exists()) {
            return;
        }
        File parentFile = file.getParentFile();
        File target = new File(parentFile, targetFile);
        if (fileFilter == null || fileFilter.filter(file)) {
            boolean b = file.renameTo(target);
            if (b) {
                System.out.println("rename " + file.getPath() + "----" + target.getPath());
            }
        }
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File temp : files) {
                batchRename(temp.getPath(), targetFile, fileFilter);
            }
        }
    }
}
